package com.tank.view;

import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

public class TankFrame extends JFrame {
	private JMenuBar menuBar;
	private JMenu gameMenu;
	private JMenuItem start;
	private JMenuItem pause;
	private TankPanel tankPanel;

	public TankFrame() {
		menuBar = new JMenuBar();
		gameMenu = new JMenu("选项");
		start = new JMenuItem("开始游戏");
		pause = new JMenuItem("暂停游戏");
		tankPanel = new TankPanel();

		start.setActionCommand("start");
		pause.setActionCommand("pause");

		start.addActionListener(tankPanel);
		pause.addActionListener(tankPanel);
		this.addKeyListener(tankPanel);

		gameMenu.add(start);
		gameMenu.add(pause);
		menuBar.add(gameMenu);
		
		this.setJMenuBar(menuBar);
		this.add(tankPanel);
	}

}
